/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Analyser.events;

import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author gianmariospacagna
 */
public class EventAgitation extends EventStartAndEnd implements Event {

    final static String description = "The child is agitated";

    public EventAgitation(long startTime, long endTime) {
        super(startTime, endTime);
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static Date getSleepingDate(long time0, long time1) {
        Date sleepingDate = new Date(time0);
        if (sameDay(new Date(time1), sleepingDate)) {
            Calendar cal = Calendar.getInstance();

            cal.setTime(sleepingDate);
            cal.add(Calendar.DATE, -1);
            sleepingDate = cal.getTime();
        }

        //System.out.println("Time0: "+new Date(time0)+" Time1: "+new Date(time1)+" SleepingDate "+sleepingDate);
        return sleepingDate;
    }
    
    
    public static boolean sameDay(Date d0, Date d1) {

        if (d0.getYear() == d1.getYear() & d0.getMonth() == d1.getMonth() & d0.getDay() == d1.getDay()) {
            return true;
        } else {
            return false;
        }
    }
}
